<?php

namespace App\Http\Controllers;

use App\MakeTable\Table;
use App\Redict\Success;
use App\Transform\TwitterCommentTransform;
use App\Transform\TwitterTransform;
use App\Twitter;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Response;

class TwitterController extends Controller
{

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $pagename = '晒图信息管理';
        $modelurl = 'twitters';
        $tablecate = ['tablecate'=>'晒图信息'];
        $headname = ['话题','内容','图片','俱乐部','发言者','发言时间','操作'];
        $tablehead = ['clubname','content','twitterPics','club','consumer','created_at','id'];
        $twitterstable = new Table($tablehead,$page = 8);
        $model = $twitterstable->viewdata(Twitter::class);
        $models = $twitterstable->viewpagedata(Twitter::class);
        return view('admin.home.tableshow',compact('tablecate','model','tablehead','models','headname','pagename','modelurl'));
    }
    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $twitter = Twitter::findOrFail($id);
        $modelurl = 'twitters';
        $pagename = $twitter->name;
        $formhead = ['话题','内容'];
        $formname = ['clubname','content'];
        $formhead = collect($formname)->zip($formhead)->toArray();
        return view('admin.home.showtwitter',compact('pagename','twitter','formhead','modelurl'));
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //删除
        Twitter::destroy($id);
        return Success::back();
    }
}
